package cn.tedu.net.collection.oopextends;

public class Test7_Extends2 {
    public static void main(String[] args) {
        Son2 s =new Son2();
        s.eat();
        Father2 f =new Father2();
        f.eat();
        s.study();
    }
}


class Father2{
    //创建父类的成员方法
     void eat(){
        System.out.println("爸爸爱你");
    }

}
class Son2 extends Father2 {
    /*
    ocp原则:面向功能修改关闭,面向功能拓展开放
     */
    //覆盖重写的规则和父类的方法保持一致
    @Override
     public void eat(){
        super.eat();
        System.out.println("儿子爱吃饺子");
    }
    public void study(){
        System.out.println("来学习Java" );
    }
}